-
Notifications
You must be signed in to change notification settings - Fork 559
Simple-Schema and to stored refactor #25962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…to toStoredRefactor
…to toStoredRefactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the simple-schema system to better distinguish between view and stored schema types, improving type safety and API clarity. The changes introduce a SchemaType enum to explicitly type schemas as either View or Stored, rename compatibility snapshot APIs for better clarity, and refactor schema transformation logic to separate concerns between format conversion and semantic transformations.
Key changes:
- Introduces
SchemaTypeenum withStoredandViewvariants to parameterize schema interfaces - Renames
encodeSimpleSchema/decodeSimpleSchematoencodeSchemaCompatibilitySnapshot/decodeSchemaCompatibilitySnapshot - Refactors schema transformation to convert view→stored simple-schema before converting to persisted format
- Adds reentrancy protection to
getUnhydratedContextfor better debugging - Removes
definitionsInternalfromTreeViewConfigurationpublic API surface
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/framework/fluid-framework/api-report/*.api.md | Removes definitionsInternal from TreeViewConfiguration in all API reports |
| packages/dds/tree/src/simple-tree/simpleSchema.ts | Adds SchemaType enum and parameterizes all simple schema interfaces with it |
| packages/dds/tree/src/simple-tree/toStoredSchema.ts | Major refactoring to transform view→stored simple-schema, then to persisted format |
| packages/dds/tree/src/simple-tree/treeSchema.ts | New file defining TreeSchema interface and createTreeSchema function |
| packages/dds/tree/src/simple-tree/createContext.ts | Adds reentrancy guard to getUnhydratedContext |
| packages/dds/tree/src/simple-tree/api/*.ts | Updates to use renamed snapshot APIs and new schema transformation functions |
| packages/dds/tree/src/simple-tree/core/*.ts | Updates to support new SchemaType parameterization and transformation options |
| packages/dds/tree/src/simple-tree/node-kinds/**/*.ts | Updates all node type interfaces to specify SchemaType.View |
| packages/dds/tree/src/test/**/*.spec.ts | Test updates to use new APIs and validate schema transformations |
| packages/dds/tree/src/shared-tree/*.ts | Updates to properly type stored schema exports as SchemaType.Stored |
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
Description
Since simple schema can now contain view schema specific data, but might also be derived from stored schema, and might also be storing only a subset of its view specific data that it can hold (like when snapshotting for compatibility tests) using it is rather error prone.
This refactoring attempts to better clarify what the semantics of a given simple schema are by allowing them to be typed as either view or stored, and providing more specific names and docs to the compatibility snapshotting APIs.
This also refactors how we generate stored schema: now we transform a simple schema for a view to a simple schema for stored schema, then convert that to the persisted format. This redesign separates the concerns for persisted format conversion and the semantics of things like staged schema which get processes when converting from view to stored.
This results in some deduplication of logic, and allows all schema transformation logic to be applied directly to simple-schema.
This change could be followed up with some further changes to better remove stored schema from the alpha APIs, and replace those APIs with use of stored-simple-schema and thus shrinking the package API surface area and making its types more interoperable.
getUnhydratedContexthas been improved to give better asserts when uses re-entrantly.Breaking Changes
Several stored and simple schema alpha APIs have been impacted, but all stable APIs should behave as is.
Reviewer Guidance
The review process is outlined on this wiki page.